<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\modules\home\models\Category */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '分类列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-view">

    <p>
        <?= Html::a('编辑', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('上传封面图', ['upload', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>
    <div class="row">
        <div class="col-md-6">

            <div class="panel panel-info">
                <div class="panel-heading">详情</div>

                <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'id',
                            [
                                'format' => 'raw',
                                'attribute' => 'cid',
                                'value' => function($model) {
                                    if($model->cid == 0){
                                        return '一级分类';
                                    }else{
                                        return $model->cid;
                                    }
                                },
                            ],
                            'title',
                            'title_desc',
                            'thumb',
                            [
                                'format' => 'raw',
                                'attribute' => 'create_at',
                                'value' => function($model) {
                                    return date('Y-m-d H:i', $model->create_at);
                                },
                            ],
                        ],
                    ]) ?>

            </div>

        </div>

        <div class="col-md-6">
            <div class="panel panel-info">
                <div class="panel-heading">封面图</div>
            </div>
        </div>

    </div>


</div>
